﻿@using MyBlog
@model MoodModel
<div style="clear:both; border-bottom:#CCC 1px solid;height:30px;line-height:30px; padding-left:10px;font-size:12px;">
    @if (UserSession.LoginUserInfo != null)
            {
        @:当前用户：<span>@UserSession.LoginUserInfo.NickName</span>
            }
    else
    {
        <div class="login-tip">会话已过期，请重新<a href="@Url.Content("~/account/login?returnUrl="+Request.Url)">登录</a></div>
    }
</div>
<div style="clear:both; padding:10px;">
    <script id="editContent" name="editContent" style="height:200px;width:100%; margin-bottom:5px;" type="text/plain">
    </script>
    <div style="clear:both; padding-bottom:3px;">
        <input type="button" id="btnok" value="发表" onclick="save()" class="btnsubmit" />
        <input type="button" id="btnClose" value="关闭" onclick="closeIframe()" class="btnsubmit" />
    </div>
</div>
<link href="~/Content/CommonStyle.css" rel="stylesheet" />
<script src="~/Scripts/jquery-1.7.1.js"></script>
<script src="~/Content/ueditor/ueditor.config.js"></script>
<script src="~/Content/ueditor/ueditor.all.js"></script>
<script type="text/javascript">
    var index = parent.layer.getFrameIndex(window.name);
    var ue2 = UE.getEditor('editContent', {
        toolbars: [
            ['undo', 'redo', 'emotion',
                'selectall', 'link', 'insertcode']],
        enableAutoSave: false,
        maximumWords: 500,
        autoHeightEnabled: false,
        autoFloatEnabled: false
    });
    ue2.ready(function () {
        ue2.setContent('@Html.Raw(Model.Content.HtmlDecode())');
        ue2.focus(true);
    });

    parent.$(function () {

    })

    function save() {
        var id = parent.$('#hID').val();
        var uid = parent.$('#huid').val();
        if (!ue2.hasContents()) {
            layerAlert('说说内容还没写哦！', function () { ue.focus(); });
            return;
        }
        parent.$.post('@Url.Action("release")', { id: id, content: parent.$.htmlEncode(ue2.getContent().replace("<p></p>","")), accountid: uid },
            function (o) {
                if (o.State == 1) {
                    parent.$('#hID').val(0);
                    parent.layerMsg('发表成功！');
                    parent.getMoodList();
                    closeIframe();
                } else {
                    parent.layerAlert('发表失败：' + o.Message);
                }
            }, "json");
    }

    function closeIframe() {
        parent.layer.close(index);
    }
</script>